import 'package:flutter/material.dart';

class HomeNav extends StatelessWidget {
  const HomeNav({super.key, required this.navList});

  final List navList;

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      // 处理listview嵌套报错
      shrinkWrap: true,
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 5, mainAxisSpacing: 10, crossAxisSpacing: 10),
      itemBuilder: (BuildContext context, int index) {
        return Container(
          color: const Color.fromARGB(255, 250, 249, 249),
          child: Column(
            children: [
              Expanded(
                  child: Image.network(navList[index]['imgUrl'],
                      width: 60, height: 60, fit: BoxFit.contain)),
              Expanded(
                  child: Padding(
                padding: const EdgeInsets.only(top: 3),
                child: Text(
                  navList[index]['text'],
                  style: const TextStyle(fontSize: 13),
                ),
              ))
            ],
          ),
        );
      },
      itemCount: navList.length,
    );
  }
}
